<?php

/**
 *   OPENSHOP 呼叫中心管理程序
 * 
 *   @link        http://baison.com.cn
 *   @copyright   Baison, Inc.
 *   @package     OpenShop
 *   @version     $Id: cc_service.php,v 1.0 2009/08/26 08:36:58 $
 *   @author      Jiajun <jiajun@baison.com.cn>
 */

define('IN_OS', true);

require(dirname(__FILE__) . '/includes/init.php');

$sql = 'select distinct user_name,password from '.$os->table('admin_user').' as u,'.$os->table('acl_role_user').' as r,' .$os->table('acl_role_func').' as f,'.$os->table('acl_action').' as a where u.user_id = r.user_id and r.role_id = f.role_id and a.action_id = f.action_id and a.action_id = '.CALL_CENTER;

$res = $db->getAll($sql);                     
                      
header('Content-Type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="utf-8"?>';

$output = arraytoXml($res,"utf-8");
echo $output;

function arraytoXml($arrays,$encoding='')
{
	if(!is_array($arrays))
	{
   		echo "<font color='red'>$arrays 不是合理的输入参数!</font>";
   		return false;
	}
	
	$xmlstr = '';
	$xmlstr .='<xml><userlist>';
	// 调用遍历数组函数	
	$xmlstr .= traversal($arrays);
	$xmlstr .='</userlist></xml>';
	return $xmlstr;
}


function traversal($admin_users)
{
	$arrString = '';
	foreach ($admin_users AS $admin_user)
	{
		$arrString .= '<user name ="'.$admin_user['user_name'].'" pwd = "'.$admin_user['password'].'"></user>';
	}
	return $arrString;
}

?>